home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lollipop / lollipop.hqx / Lollipop Manual / list.tex < prev    next >
Text File  |  1992-11-18  |  15KB  |  420 lines

  1. % List.tex copyright 1992 Victor Eijkhout
  2. \Chapter Lists
  3.  
  4. Lists in Lollipop are defined by \refcs{DefineList}:
  5.  
  6. \Ver>\DefineList:Foo [...]
  7.     item:start [...] item:stop
  8.     [...] Stop<Rev
  9. and the resulting list is used as
  10. \Ver>\Foo
  11. \item [ ..text.. ]
  12. \item [ ... ]
  13. \FooStop<Rev
  14. where the closing command can be abbreviated as~\cs{>}.
  15.  
  16. \Section Label alignment
  17.  
  18. In general there is a default position for labels; 
  19. either aligning with the
  20. left or the right side of the margin over which the list is indented.
  21. The two ways are indicated with the option \refopt{item}:
  22. \Ver>    item:left [...] item:stop<Rev
  23. and \Ver>    item:right [...] item:stop<Rev respectively.
  24. Specifying \opt{item:start} gives the default left aligning position.
  25.  
  26. \Example
  27. \DefineList:enumerate
  28.     item:start itemCounter ) item:stop Stop
  29. \DefineList:enumerateright
  30.     item:right ( itemCounter ) Spaces:1 item:stop Stop
  31. \enumerate\item Some item
  32. \item And another
  33. \enumerateright\item First nested item
  34. \item Next nested item\>
  35. \item And back to the original list.\>
  36. \ExampleStop
  37.  
  38. \Section List indentation
  39.  
  40. The amount over which the text of a list (excluding the item labels)
  41. is indented is controled by a list of indentations. This is explained
  42. in section~\ref[sec:indent:control]. The indentation amount is most of
  43. the time also equal to the value of the paragraph indentation outside
  44. that list.
  45.  
  46. In the rare case where the indentation of a list has to be controlled
  47. explicitly, there is an option \refopt{indentation} with one value.
  48. \Ver>\DefineList:SomeList indentation=30pt [...] Stop<Rev
  49.  
  50.  
  51. \Section Label style
  52.  
  53. Every list that uses the \refopt{itemsign} option is an `itemize' list,
  54. no matter what it's name, and there is a counter in Lollipop that
  55. keeps track of how deep you are in itemize lists. Similarly, every
  56. list that uses \refopt{itemCounter} is an `enumerate' lists, and these
  57. are counted too.
  58.  
  59. On every next level a new style of item sign or counter is used. For
  60. item signs this is in sequence: $\bullet$, $\circ$, --, and $\cdot$
  61. for all higher levels. The style of sign can be changed by
  62. \refcs{SetItemSign}: \Ver>\SetItemSign:6=m<Rev where the letter
  63. indicating the sign is interpreted as: \n b~$\bullet$ (bullet), \n
  64. c~$\circ$ (circle), \n d~$\diamond$ (diamond), \n m~--- (em-dash), \n
  65. n~-- (en-dash), \n .~$\cdot$.
  66.  
  67. Similarly, the counter style can be set by
  68. \refcs{SetItemCounterRepresentation}:
  69. \Ver>\SetItemCounterRepresentation:2=i<Rev where the letter
  70. representing the style is interpreted as: 1~Arabic, I~uppercase roman,
  71. i~lowercase roman, A~uppercase characters, a~lowercase characters.
  72.  
  73. \Section Label width
  74.  
  75. The default width for a label is at most the width of the margin over
  76. which the list is indented. Using \opt{item:left} or \opt{item:right}
  77. will have the label pushed to the left or right side of this margin
  78. respectively. Now what if the label material is wider than this
  79. margin? Usually you want the label then to expand to the right, and
  80. that is indeed what happens, unless you specify
  81. \refopt{labeloverflow} with value \n{left}, in which case the right
  82. boundary of the label will not budge, and the label will start
  83. protruding into the outer margin.
  84.  
  85. \Section[sec:description:list] Description lists
  86.  
  87. A common type of list is the type where each item label consists of a
  88. piece of text. Such a list is called a `description' list in
  89. \Lollipop, and it recognized by the occurrence of the option
  90. \refopt{description} in its definition. A~description list can also use
  91. the item sign or the item counter, of course.
  92.  
  93. Using a description list, the description text is everything that
  94. follows the command \cs{item}, up to the end of the line.
  95.  
  96. \Example
  97. \DefineList:TestList 
  98.  item:left Style:bold itemCounter . Spaces:1 description
  99.       Spaces:2 item:stop Stop
  100. \TestList\item Do
  101. A deer, a female deer.\item Re
  102. According to mr. Fowler only a legal term.
  103. \item Mimi Jett
  104. The owner/founder of ETP\>
  105. \ExampleStop
  106.  
  107. As you can see, the problem of label overflow can easily occur with
  108. description lists. Thus it is a good idea to end the item material
  109. with some white space, as in the above example.
  110.  
  111.  Exceptional situation:
  112. if you use an empty description text, you should write \ver>\item{}>.
  113.  
  114. \Section Suspended lists
  115.  
  116. Occasionally the is a need to resume an enumerate list, that is,
  117. after a piece of text that is not part of the list an enumerate list
  118. should start counting from the previous value on. In \Lollipop\ this
  119. phenomenon can be realized by never ending the enumerate list, and
  120. simply moving the text one indentation level back with
  121. \refcs{PopIndentLevel}.
  122.  
  123. \Example
  124. \DefineList:enumerate item:left itemCounter item:stop Stop
  125. \enumerate\item First some item\par
  126. {\PopIndentLevel \Indent:no
  127. This text seems to be outside the list. Don't you believe it.\par}
  128. \item And another item\>
  129. \ExampleStop
  130.  
  131. Note that the `popped' text has to be in a group (otherwise the
  132. subsequent items will also be popped back), and it has to be
  133. separated from the preceding and following text by \cs{par}; the
  134. trailing \cs{par} has to be in the group.
  135.  
  136. \Section Item counter manipulation
  137.  
  138. The item counter can be manipulated explicitly. This is necessary for
  139. instance for starting a list at another value than one. What you need
  140. to realize here is that the command \cs{item} starts by incrementing
  141. the counter. Furthermore, the only way to access the item counter is
  142. through the commands for counters; see section~\ref[sec:counters].
  143.  
  144. \Example
  145. \DefineList:enumerate item:left itemCounter item:stop Stop
  146. \enumerate \SetCounter:item=-1
  147. \item Escape: usually the backslash.
  148. \item Begin Group.\>
  149. \ExampleStop
  150.  
  151. \Section List titles and list tails
  152.  
  153. Lists can have titles. The title follows the command that invokes the
  154. list, in the usual manner. Material to follow the list can also be
  155. specified: anything following the option \refopt{text} is considered to
  156. be trailing material.
  157.  
  158. \Example
  159. \DefineList:TestList hrule line:start Style:bold title line:stop
  160.  item:left Style:italic itemCounter item:stop
  161.  text vwhite:3pt hrule Stop
  162. \TestList In the last fiscal year, have you:\par
  163. \item Eaten peanuts? \item Walked the dog?
  164. \item Bought a Frank Zappa record?\>
  165. \ExampleStop
  166.  
  167. In case you wonder what happens with textual material after
  168. \opt{item:stop} and before any \opt{text}, well, that is taken to be
  169. inserted immediately after each item label.
  170.  
  171. \Section Between the items
  172.  
  173. There are special list options controlling what happens in between
  174. items. \Lollipop\ has an option \refopt{breakbetween}, analogous to
  175. \opt{breakbefore} and \opt{breakafter}; see
  176. section~\ref[sec:opt:penalties]. This item be default has a
  177. value of~\n{$-50$}, implying that breaks in between items
  178. should be preferred slightly over breaks in between the
  179. lines of an item.
  180.  
  181. Similarly, there is an option \refopt{whitebetween}
  182. controlling the amount of white space in between items that is
  183. analogous to \opt{whitebefore} and \opt{whiteafter}. Like these two
  184. options, it can also be set by the \cs{Distance} command
  185. (section~\ref[sec:com:distance]).
  186.  
  187. \Section Indentation in lists
  188.  
  189. An item can be considered to be consisting of at least one paragraph.
  190. That paragraph is never indented. For the behaviour of any next
  191. paragraph within the same item, the option \refopt{indentinside} can be
  192. used. This option has values yes/no. In case paragraphs inside an
  193. item indent, the indentation amount is level-controlled; see
  194. section~\ref[sec:indent:control].
  195.  
  196. \Chapter[chap:text:block] Text Blocks
  197.  
  198. The `text block' is a way of treating a moderate sized chunk of text
  199. in a different  way from the surrounding text. Text blocks are
  200. created by \refcs{DefineTextBlock}. Here is a small example.
  201.  
  202. \Example
  203. \DefineTextBlock:Quote 
  204.  PushIndentLevel PointSize:9 SetFont text Stop
  205. \Indent:no In some context it has been written that
  206. \Quote No man is an island.\QuoteStop
  207. In another:
  208. \Quote Run don't walk to the nearest island.\>
  209. Sometimes one would wish women weren't so logical.
  210. \ExampleStop
  211.  
  212. Note that the text block has an explicit closing command,
  213. consisting of the name of the block followed by \opt{Stop},
  214. and that implicit closing by \cs{>} is possible.
  215.  
  216. \Section The \opt{text} option
  217.  
  218. Text blocks have only one specific option: \refopt{text}. This option
  219. is used to separate material heading the block from material trailing
  220. the block. Example:
  221.  
  222. \Example
  223. \DefineTextBlock:DisplayEq 
  224.  whitebefore:abovedisplayskip whiteafter:belowdisplayskip
  225.  line:start white:parindent $ displaystyle text $ line:stop Stop
  226. The formula
  227. \DisplayEq e^{\pi i}+1=0\>
  228. contains nature's five most interesting constants.
  229. \ExampleStop
  230.  
  231. Here one dollar comes before the text, and one after, so the first is
  232. inserted by \cs{DisplayEq} and the second by the corresponding
  233. closing command.
  234.  
  235. \Section More examples
  236.  
  237. A text block can encompass more than one paragraph, so the options
  238. \opt{indentinside} and \opt{indentfirst} are particularly useful here.
  239.  
  240. \Example
  241. \AlwaysIndent:no
  242. \DefineTextBlock:TestBlock PushIndentLevel
  243.  indentafter:yes indentfirst:no indentinside:yes 
  244.  text unskip hfill $ bullet $ par Stop
  245. One paragraph.\par The next paragraph
  246. \TestBlock Inside the block one paragraph.\par
  247. Inside the block the next paragraph.\>
  248. Outside the following paragraph.\par And the last paragraph.
  249. \ExampleStop
  250.  
  251. \ImpNote 
  252. \iSection[imp:gen:open:close] The environment in generic constructs
  253.  
  254. The text block is just about the purest use of the \Lollipop\
  255. environment mechanism. Here is how a text block is defined:
  256. \Ver>
  257. \def\@DefineTextBlock{
  258.     \csarg\edef{\@name}{\@gen@open
  259.         \the\before@coms
  260.         }
  261.     \@DefineStopCommand{\the\after@coms \@gen@close}
  262.     }<Rev
  263.  
  264. The \cs{before@coms} and \cs{after@coms} are two token lists with
  265. the heading and trailing commands.
  266.  
  267. It is important to note that the definition of the control sequence
  268. of the block is defined by \cs{edef}. This first of all unwraps the
  269. token lists, but it also has an important effect on
  270. \cs{@gen@open/close}. These control sequences contain a lot of
  271. conditionals which, in combination with the \cs{edef} give a really
  272. dynamic definition of generic constructs in \Lollipop.
  273.  
  274. First of all, the opening and closing commands induce a group
  275. so that various quantities can be set locally.
  276. \Ver>
  277. \def\@gen@open{\outer@start@commands 
  278.     \begingroup \inner@start@commands}
  279. \def\@gen@close{\inner@end@commands 
  280.     \endgroup \outer@end@commands}<Rev
  281.  
  282. The outer start commands concern global actions such as backspacing
  283. previous skips, incrementing counters and setting references.
  284. \Ver>
  285. \def\outer@start@commands{%
  286.     \iftext@construct
  287.         \ifleft@embedded@construct
  288.               \nxp\bsp@hack
  289.         \else \nxp\leavehmode \nxp\bvwit{\the\@whitebefore}\fi<Rev
  290. The `embedded construct' tests are only true if the construct
  291. can be embedded in a paragraph. A~rare occurence most of the time.
  292. \Ver>
  293.         % backspace previous white space while it's visible
  294.         \nxp\if@headed\nxp\else
  295.             \ifforced@break@before\@beforepenalty
  296.             \else\nxp\ifnum\lastpenalty=\z@
  297.                          \@beforepenalty\nxp\fi
  298.             \fi
  299.         \nxp\fi<Rev
  300. A subtle point: a preceding heading will have placed \cs{nobreak} 
  301. followed by a skip. It is dangerous to place any sort of penalty
  302. after this because it might induce a page break.
  303.  
  304. Now the counter, title, and stuff connected to that.
  305. \Ver>
  306.     \fi
  307.     \ifhas@counter \nxp\StepCounter:\expandafter\@name\@space
  308.         % This sets the \current@label by default<Rev
  309. Since this is used inside an \cs{edef} we can use some trickery
  310. to get the space token after the argument to \cs{StepCounter}.
  311. \Ver>
  312.         \ifhas@marks \edef\nxp\cs@e
  313.                {\nxp\nxp\nxp\refresh@mark@item
  314.                 {\@name Counter}{\CSname{\@name Counter}}}%
  315.             \nxp\cs@e      
  316.         \fi
  317.         \fi
  318.     \iflabel@defined 
  319.         \global\current@label={\the\@labelcoms}\fi
  320.     \ifhas@title \install@title@code<Rev
  321. This title business is explained in~\ref[imp:install:title].
  322. This piece of code also refreshes the title in the mark structure.
  323. This has to be done after any page break for the benefit
  324. of headers/footers.
  325. \Ver>
  326.     \fi
  327.     \ifhas@marks\nxp\ifnin{\nxp\place@mark}\fi
  328.         %otherwise IniTeX'ing Lollipop will output a page
  329.     \nxp\xx@label\the\extern@toks\penalty\@M
  330.         % also subtle: if this white space would be higher, it would
  331.         % be invisible because of marks et cetera.
  332.         % insert nobreak after marks/writes to prevent page breaks.
  333.     \iftext@construct
  334.         \ifleft@embedded@construct
  335.               \else \nxp\@vwhite{\the\@whitebefore}\fi
  336.     \fi
  337.     }<Rev
  338.  
  339. Inner start commands are concerned with setting local values.
  340. \Ver>
  341. \def\inner@start@commands{%
  342.     \nxp\Open@Group\CSname{\@class}\CSname{\@name}%<Rev
  343. The \cs{Open@Group} call makes it possible to track down groups
  344. that have inadvertendly been left open. Since we now know the
  345. name we can give helpful error msgs.
  346. \Ver>
  347.     \install@stop<Rev
  348. Install the right implicit closing, see~\ref[sec:implicit:close]
  349. and~\ref[imp:implicit:close].
  350. \Ver>
  351.     \ifleft@embedded@construct
  352.     \else \nxp\hold@parskip 
  353.         \nxp\@defaulteverypar
  354.         \ifwhiteleft@defined \advance\leftskip \the\@whiteleft \relax \fi
  355.         \ifwhiteright@defined \advance\rightskip \the\@whiteright \relax \fi
  356.         \nxp\let\nxp\par=\nxp\@par %explain to me again why this is necessary...
  357.         \inside@indent \first@indent
  358.     \fi
  359.     \advance\nest@depth\@ne<Rev
  360. The nest depth is used for determining indentation levels.
  361. \Ver>
  362.     }<Rev
  363.  
  364. End commands set up some conditions, most of which will be tested
  365. by the start of any next construct.
  366. \Ver>
  367. \def\inner@end@commands{%
  368.     \nxp\Close@Group\CSname{\@class}\CSname{\@name}%
  369.     \ifright@embedded@construct \else \nxp\leavehmode \fi
  370.     \@afterpenalty
  371.     \ifright@embedded@construct \else \nxp\@vwhite{\the\@whiteafter}\fi
  372.     }
  373. \def\outer@end@commands{%
  374.     \the\after@toks
  375.     \ifright@embedded@construct 
  376.         \nxp\@headedno \nxp\esp@hack
  377.     \else
  378.         \after@indent \nxp\dono@parskip
  379.     \fi}<Rev
  380.  
  381. \iSection[imp:implicit:close] Implicit closing
  382.  
  383. Constructs with an explicit closing command, lists and text blocks,
  384. can be closed by~\cs{>}, which simply closes the current
  385. construct. A~more drastic version, \cs{>]}, closes all currently
  386. open constructs.
  387. \Ver>
  388. \def\outer@stop@command{\Emessage{Vacuous group closing}}
  389. \let\default@stop@command\outer@stop@command
  390. \def\>{\default@stop@command%[fool the editor
  391.     \ifNextChar]{%
  392.         \ifx\default@stop@command\outer@stop@command
  393.             \xp\take@one
  394.         \else \xp\>\fi}{}}<Rev
  395. The \cs{outer@stop@command} is meant to give an error msg if the
  396. user attempts to close a group while none is open.
  397.  
  398. The current meaning of~\cs{>} is installed in
  399. \cs{inner@start@commands}:
  400. \Ver>
  401. \def\install@stop{\if@implicitclose
  402.         \def\nxp\default@stop@command
  403.                {\CSname{\stop@command}}%
  404.     \else \let\nxp\default@stop@command
  405.               \nxp\outer@stop@command 
  406.     \fi}<Rev
  407.  
  408. By default, constructs can be closed implicitly, but there is an
  409. option \refopt{noimplicitclose} to disable this.
  410. \Ver>
  411. \newif\if@implicitclose
  412. \add@generic@default{\@implicitcloseyes}
  413. \@GenericOption{noimplicitclose}{\@implicitcloseno}<Rev
  414. This option is for instance used in the examples in this manual.
  415. Otherwise closing a construct in the example would also close the
  416. example itself.
  417.  
  418. \ImpNoteStop
  419.